import etcd3

class EtcdService:
    service_name = "my_service"
    service_address = "http://127.0.0.1:2379"
    service_id = "my_service_id"
    etcd = None

    def __init__(self):
        self.register_service()

    def register_service(self):
        etcd = etcd3.client(user="root",password="123456", grpc_options={
            'grpc.http2.true_binary': 1,
            'grpc.http2.max_pings_without_data': 0,
        }.items())
        etcd.put("service_py_img_handler", b'\x01')
        print(f"Service '{self.service_name}' registered with address '{self.service_address}'")

    def deregister_service(self):
        self.etcd.delete(self.service_name)

etcd_service = EtcdService()